package lab02.test17;

/**
 * Created by ASUS on 2017/10/26.
 */
public class Test {

    public static void main(String[] args) {

        //实例化操作
        // 数据类型
        //（1）基本数据类型：short,int,double,float....
        //(2)复合数据类型：数组，类，接口

        int[] numbers =new int[10];
        //输出该数组中的最大值、最小值、所有元素总和
        // 以及最大值和最小值在该数组中的位置
        numbers[0] = 13;
        numbers[1] = 9;
        numbers[2] = 56;
        numbers[3] = 34;
        numbers[4] = 26;

        //1.打印所有元素的值
        //ctrl+d 复制一行
        //ctrl+x 删除一行
        //System.out.println(numbers[0]);
        //System.out.println(numbers[1]);
        //System.out.println(numbers[2]);
        //System.out.println(numbers[3]);
        //System.out.println(numbers[4]);

        //下标：index 取值（0-4）
        int index;

        for (index = 0; index < 5; index ++){
            System.out.println(numbers[index]);

        }
        //输出数组的最大值、最小值
        int max = 0;

        for (int i = 0; i < numbers.length; i ++){

            if (numbers[i] > max){
                max = numbers[i];
            }
        }
        System.out.println("max is:" + max);

        int min = 9;

        for (int i = 4; i >= 0; i --){

            if (numbers[i] < min){
                min = numbers[i];
            }
        }
        System.out.println("min is:" + min);

        //求和
        int sum = 0;
        for (int i = 0; i < numbers.length; i ++){
            sum += numbers[i];
        }
        System.out.println("sum is:" + sum);
    }
}
